home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tool-inc.zip / LONGJMP.INC < prev    next >
Text File  |  1989-03-01  |  1KB  |  28 lines

  1.  
  2.   type
  3.      JumpRec = array[1..6] of byte;
  4.  
  5.   procedure SetJump(VAR Save : JumpRec);
  6.     {save the machine state and the pc for a later jump, longjumps
  7.      will return to where SetJmp was called}
  8.   begin
  9.     inline($8B/$5E/$04/ {mov bx,[bp+4]  ;get address of jump record}
  10.       $89/$E8/          {mov ax,bp      ;current bp}
  11.       $05/$08/$00/      {add ax,8       ;the sp when call was made}
  12.       $89/$07/          {mov [bx],ax    ;store in spreg}
  13.       $8B/$46/$00/      {mov ax,[bp]    ;caller'S BP}
  14.       $89/$47/$02/      {mov [bx+2],ax  ;store in bpreg}
  15.       $8B/$46/$02/      {mov ax,[bp+2]  ;the return address}
  16.       $89/$47/$04);     {mov [bx+4],ax  ;store in jmpadr}
  17.   end;
  18.  
  19.   procedure LongJump(Save : JumpRec);
  20.     {restore the machine state and make the jump}
  21.   begin
  22.     inline($8B/$5E/$08/ {mov bx,[bp+8]   ;get jump adress}
  23.       $8B/$66/$04/      {mov sp,[bp+4]   ;restore sp}
  24.       $8B/$6E/$06/      {mov bp,[bp+6]   ;and also bp}
  25.       $FF/$E3);         {jmp bx          ;make the long jump}
  26.   end;
  27.  
  28.